<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="new :: common_head(${deviceName})">
</head>
<style>
    .noBorder{
        border: none;
    }
    .mylabel{
        display: inline;
    }
    .greenColor{
        color:green;
    }
    .redColor{
        color:red;
    }
</style>

<body>
<!--删除提示模态框1-->
<div class="modal fade" id="delcfmModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel">提示</h4>
            </div>
            <div class="modal-body">是否要删除？</div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" onclick="deleteProperty()">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<!--删除提示模态框结束-->
<!--删除提示模态框2-->
<div class="modal fade" id="delcfmModel1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel1" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel1">提示</h4>
            </div>
            <div class="modal-body">是否要删除？</div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" onclick="deletePropertyById()">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<!--删除提示模态框结束-->
<div class="modal fade" id="delcfmModel2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel2">提示</h4>
            </div>
            <div class="modal-body">是否要删除？</div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" onclick="deleteRelation1()">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<!--删除提示模态框结束-->
<!-- start: Header -->
<div th:replace="~{new::header}"></div>
<!-- start: Header -->

<div class="container-fluid-full">
    <div class="row-fluid">

        <!-- start: Main Menu -->
        <div id="sidebar-left" class="span2" th:replace="new::sidebar_left"></div>
        <!-- end: Main Menu -->

        <noscript>
            <div class="alert alert-block span10">
                <h4 class="alert-heading">Warning!</h4>
                <p>You need to have <a href="" target="_blank">JavaScript</a> enabled to use this site.</p>
            </div>
        </noscript>

        <!-- start: Content -->
        <div id="content" class="span10">


            <ul class="breadcrumb">
                <li>
                    <i class="icon-home"></i>
                    <a th:href="@{/new.html}">主页</a>
                    <i class="icon-angle-right"></i>
                </li>
                <li><a href="#">[[${deviceName}]]信息修改</a></li>
            </ul>

            <div class="row-fluid sortable">
                <div class="box span12">
                    <div class="box-header" data-original-title>
                        <h2><i class="halflings-icon white edit"></i><span class="break"></span>[[${deviceName}]]属性管理</h2>
                    </div>
                    <div class="box-content">
                        <form class="form-horizontal" id="form2"  enctype="multipart/form-data" method="post">
                            <input type="hidden" id="typeId" th:value="${device.deviceType.typeId}">
                            <fieldset>
                                <div class="control-group">
                                    <label class="control-label">设备ID</label>
                                    <div class="controls">
                                        <span class="input-xlarge uneditable-input"  id="deviceId" th:value="${device.deviceId}" th:text="${device.deviceId}"></span>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">设备名</label>
                                    <div class="controls">
                                        <input class="input-xlarge focused" type="text" placeholder=""
                                             th:value="${device.deviceName}"  onchange="checkName()" id="deviceName" name="deviceName">
                                        <div style="display: inline" id="checkName">
                                        </div>
                                        <span style="color:red;font-size: 20px" >*</span>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">能量编码</label>
                                    <div class="controls">
                                        <input class="input-xlarge focused" type="text" placeholder=""
                                               th:value="${device.devCode}"  id="devCode" name="devCode">
                                        <span style="color:red;font-size: 20px" >*</span>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">电量编码</label>
                                    <div class="controls">
                                        <input class="input-xlarge focused" type="text" placeholder=""
                                               th:value="${device.batteryCode}"  id="batteryCode" name="batteryCode">
                                        <span style="color:red;font-size: 20px" >*</span>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">内温编码</label>
                                    <div class="controls">
                                        <input class="input-xlarge focused" type="text" placeholder=""
                                               th:value="${device.temperatureCode}"  id="temperatureCode" name="temperatureCode">
                                        <span style="color:red;font-size: 20px" >*</span>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">所属图谱</label>
                                    <div class="controls">
                                        <span class="input-xlarge uneditable-input"  id="graphId" name="graphId" th:value="${device.graphId}" th:text="${graphName}"></span>
                                        <!--<select id="graph" class="select" name="graphId">-->
                                            <!--<option th:each="graph,graphStat:${graphList}" name="graphId" th:value="${graph.graphId}" th:text="${graph.graphName}"-->
                                            <!--th:selected="${device.graphId == graph.graphId}"></option>-->
                                        <!--</select>-->
                                    </div>
                                </div>
                                <div class="control-group" th:if="${device.deviceType.typeId==3}">
                                    <label class="control-label">是否纳入决策</label>
                                    <div class="controls">
                                        <label class="radio" ><input  name="isPredicted" th:attr="checked=${device.isPredicted == 1?true:false}" type="radio" value="1">是</label>
                                        <div style="clear:both"></div>
                                        <label class="radio"><input  name="isPredicted" th:attr="checked=${device.isPredicted == 0?true:false}" type="radio" value="0">否</label>
                                    </div>
                                </div>
                                <div class="control-group" >
                                    <label class="control-label">是否显示在图谱上</label>
                                    <div class="controls">
                                        <label class="radio" ><input  name="isInGraph" th:attr="checked=${device.isInGraph == 1?true:false}" type="radio" value="1">是</label>
                                        <div style="clear:both"></div>
                                        <label class="radio"><input  name="isInGraph" th:attr="checked=${device.isInGraph == 0?true:false}" type="radio" value="0">否</label>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">平均每小时产能量</label>
                                    <div class="controls">
                                        <input class="input-xlarge focused" type="number" placeholder=""
                                             th:value="${device.power}" id="power" name="power">
                                        <span style="font-size: 20px" >kW</span>
                                        <span style="color:red;font-size: 20px" >*</span>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">能效比</label>
                                    <div class="controls">
                                        <input class="input-xlarge focused" type="number" placeholder=""
                                               th:value="${device.conversionRate}"  id="conversionRate" name="conversionRate">
                                        <span style="color:red;font-size: 20px" >*</span>
                                    </div>
                                </div>
                                <!--<div class="control-group" th:if="${#arrays.isEmpty(relationship)&&device.deviceType.typeId!=3}">-->
                                    <!--<label class="control-label">关联设备</label>-->
                                    <!--<div class="controls">-->
                                        <!--<select id="relDevice" class="select" name="relationDevice">-->
                                            <!--<option value="" name="relationDevice"></option>-->
                                        <!--</select>-->
                                        <!--&lt;!&ndash;<label class="mylabel">能耗比:</label>&ndash;&gt;-->
                                        <!--&lt;!&ndash;<input class="input-small focused" type="text" placeholder=""&ndash;&gt;-->
                                               <!--&lt;!&ndash;name="conversionRate">&ndash;&gt;-->
                                        <!--<label class="mylabel" >损耗率:</label>-->
                                        <!--<input class="input-small focused" type="text" placeholder=""-->
                                               <!--name="lossRate">-->
                                        <!--<input type="button" onclick="addRelation()" id="addRel" value="+">-->
                                        <!--&lt;!&ndash;<button type="button" onclick="addRelation()">+</button>&ndash;&gt;-->
                                    <!--</div>-->
                                <!--</div>-->
                                <!--<div class="control-group"  th:each="relation,relationStat:${relationship}">-->
                                    <!--<input type="hidden" th:id="'relId'+${relationStat.index}" name="relId" class="myRelId" th:value="${relation.id}">-->
                                    <!--<label class="control-label">关联设备</label>-->
                                    <!--<div class="controls">-->
                                        <!--<select th:id="'select'+${relationStat.index}" class="select"  name="relationDevice">-->
                                            <!--<option value=""  name="relationDevice"></option>-->
                                        <!--</select>-->
                                        <!--&lt;!&ndash;<label class="mylabel">能效比:</label>&ndash;&gt;-->
                                        <!--&lt;!&ndash;<input class="input-small focused" th:value="${relation.conversionRate}" type="number" placeholder=""&ndash;&gt;-->
                                               <!--&lt;!&ndash;name="conversionRate">&ndash;&gt;-->
                                        <!--<label class="mylabel" >损耗率:</label>-->
                                        <!--<input class="input-small focused" type="number" placeholder=""-->
                                               <!--name="lossRate" th:value="${relation.lossRate}">-->
                                        <!--<label class="mylabel" >能源属性:</label>-->
                                        <!--<select th:id="'propertySelect'+${relationStat.index}" class="select1"  name="energyTypeId">-->
                                            <!--<option value=""  name="energyTypeId"></option>-->
                                        <!--</select>-->
                                        <!--&lt;!&ndash;<button th:if="${relationStat.index>=1}" class="btn btn-danger myBtn" type="button" data-target="#delcfmModel2" >删除</button>&ndash;&gt;-->
                                        <!--<button th:if="${relationStat.index>=1}"  th:id="'relId'+${relation.id}" type="button" class="btn btn-danger" onclick="deleteRelation()" >删除</button>-->
                                        <!--&lt;!&ndash;<button id="btn0" th:if="${relationStat.index>=1}" class="btn btn-primary myBtn" type="button" data-target="#delcfmModel">删除</button>&ndash;&gt;-->
                                        <!--<input th:if="${relationStat.index==0}" type="button" onclick="addRelation()" id="addRel" value="+">-->
                                        <!--&lt;!&ndash;<button type="button" onclick="addRelation()">+</button>&ndash;&gt;-->
                                    <!--</div>-->
                                <!--</div>-->
                                <div class="control-group">
                                    <label class="control-label">上限</label>
                                    <div class="controls">
                                        <input class="input-xlarge focused" type="number" placeholder=""
                                              th:value="${device.cap}" name="cap" id="cap">
                                        <span style="font-size: 20px" >kWh</span>
                                        <span style="color:red;font-size: 20px" >*</span>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">设备开启时间</label>
                                    <div class="controls">
                                        <!--<input class="input-xlarge focused" type="text" placeholder=""-->
                                        <!--name="cap" id="cap">-->
                                        <select name="time" id="timeStart">
                                            <option th:selected="${startTime eq '0'}" value="0">0:00</option>
                                            <option th:selected="${startTime eq '1'}" value="1">1:00</option>
                                            <option th:selected="${startTime eq '2'}" value="2">2:00</option>
                                            <option th:selected="${startTime eq '3'}" value="3">3:00</option>
                                            <option th:selected="${startTime eq '4'}" value="4">4:00</option>
                                            <option th:selected="${startTime eq '5'}" value="5">5:00</option>
                                            <option th:selected="${startTime eq '6'}" value="6">6:00</option>
                                            <option th:selected="${startTime eq '7'}" value="7">7:00</option>
                                            <option th:selected="${startTime eq '8'}" value="8">8:00</option>
                                            <option th:selected="${startTime eq '9'}" value="9">9:00</option>
                                            <option th:selected="${startTime eq '10'}" value="10">10:00</option>
                                            <option th:selected="${startTime eq '11'}" value="11">11:00</option>
                                            <option th:selected="${startTime eq '12'}" value="12">12:00</option>
                                            <option th:selected="${startTime eq '13'}" value="13">13:00</option>
                                            <option th:selected="${startTime eq '14'}" value="14">14:00</option>
                                            <option th:selected="${startTime eq '15'}" value="15">15:00</option>
                                            <option th:selected="${startTime eq '16'}" value="16">16:00</option>
                                            <option th:selected="${startTime eq '17'}" value="17">17:00</option>
                                            <option th:selected="${startTime eq '18'}" value="18">18:00</option>
                                            <option th:selected="${startTime eq '19'}" value="19">19:00</option>
                                            <option th:selected="${startTime eq '20'}" value="20">20:00</option>
                                            <option th:selected="${startTime eq '21'}" value="21">21:00</option>
                                            <option th:selected="${startTime eq '22'}" value="22">22:00</option>
                                            <option th:selected="${startTime eq '23'}" value="23">23:00</option>
                                        </select >
                                        <span>至</span>
                                        <select name="time" id="timeEnd" >
                                            <option th:selected="${endTime eq '0'}" value="0">0:00</option>
                                            <option th:selected="${endTime eq '1'}" value="1">1:00</option>
                                            <option th:selected="${endTime eq '2'}" value="2">2:00</option>
                                            <option th:selected="${endTime eq '3'}" value="3">3:00</option>
                                            <option th:selected="${endTime eq '4'}" value="4">4:00</option>
                                            <option th:selected="${endTime eq '5'}" value="5">5:00</option>
                                            <option th:selected="${endTime eq '6'}" value="6">6:00</option>
                                            <option th:selected="${endTime eq '7'}" value="7">7:00</option>
                                            <option th:selected="${endTime eq '8'}" value="8">8:00</option>
                                            <option th:selected="${endTime eq '9'}" value="9">9:00</option>
                                            <option th:selected="${endTime eq '10'}" value="10">10:00</option>
                                            <option th:selected="${endTime eq '11'}" value="11">11:00</option>
                                            <option th:selected="${endTime eq '12'}" value="12">12:00</option>
                                            <option th:selected="${endTime eq '13'}" value="13">13:00</option>
                                            <option th:selected="${endTime eq '14'}" value="14">14:00</option>
                                            <option th:selected="${endTime eq '15'}" value="15">15:00</option>
                                            <option th:selected="${endTime eq '16'}" value="16">16:00</option>
                                            <option th:selected="${endTime eq '17'}" value="17">17:00</option>
                                            <option th:selected="${endTime eq '18'}" value="18">18:00</option>
                                            <option th:selected="${endTime eq '19'}" value="19">19:00</option>
                                            <option th:selected="${endTime eq '20'}" value="20">20:00</option>
                                            <option th:selected="${endTime eq '21'}" value="21">21:00</option>
                                            <option th:selected="${endTime eq '22'}" value="22">22:00</option>
                                            <option th:selected="${endTime eq '23'}" value="23">23:00</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">X坐标</label>
                                    <div class="controls">
                                        <input class="input-xlarge focused" type="number" placeholder=""
                                             th:value="${device.xCoordinates}" id="x" name="xCoordinates">
                                        <span style="color:red;font-size: 20px" >*</span>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">Y坐标</label>
                                    <div class="controls">
                                        <input class="input-xlarge focused" type="number" placeholder=""
                                            th:value="${device.yCoordinates}" id="y"  name="yCoordinates">
                                        <span style="color:red;font-size: 20px" >*</span>
                                    </div>
                                </div>
                                <div class="control-group" >
                                    <label class="control-label">设备图片</label>
                                    <div class="controls" style="position: relative">
                                        <!--<img th:src="'data:image/png;base64,'+${device.picPath}"/>-->
                                        <input class="input-xlarge focused" onchange="previewPic()" type="file" accept="image/jpg,image/jpeg,image/png,image/PNG" placeholder=""
                                               name="pic" id="pic">
                                    </div>
                                    <div  style="width: 80px;height: 80px;background-color: #578ebe;margin-left: 180px">
                                     <img id="showImg" style="width: 80px;height: 80px;" th:src="${device.picPath}"/>
                                    </div>

                                </div>
                                <div class="control-group">
                                    <label class="control-label">高亮图片</label>
                                    <div class="controls" style="position: relative">
                                        <input class="input-xlarge focused" accept="image/jpg,image/jpeg,image/png,image/PNG" type="file" placeholder=""
                                               name="pic" onchange="previewPic1()" id="highlightPic">
                                    </div>
                                    <div  style="width: 80px;height: 80px;background-color: #578ebe;margin-left: 180px">
                                     <img id="showImg1" style="width: 80px;height: 80px;" th:src="${device.highlightPicPath}"/>
                                    </div>
                                </div>
                                <div class="control-group" th:each="property:${device.propertyList}">
                                    <input type="hidden" th:value="${property.propertyId}" name="propertyId">
                                    <input class="control-label noBorder" placeholder="属性名" name="propertyName" th:value="${property.propertyDes}">
                                    <div class="controls">
                                        <input class="input-xlarge focused" type="text" th:value="${property.propertyValue}" name="propertyValue">
                                        <!--<a th:id="property+${property.propertyId}" class="btn btn-danger" href="javascript:void(0)" th:onclick="'javascript:deletePropertyById('+${property.propertyId}+');'">删除</a>-->
                                        <!--<a th:id="${property.propertyId}" href="javascript:void(0)" class="btn btn-danger" onclick="deleteProperty1()" >删除</a>-->
                                        <button th:id="${property.propertyId}"  type="button" class="btn btn-danger" onclick="deleteProperty1()"  >删除</button>
                                    </div>
                                </div>
                                <div class="form-actions">
                                    <button type="submit" class="btn btn-primary" onclick="editDevice();return false">提交</button>
                                    <button type="button" onclick="toDevice()" class="btn btn-primary">返回</button>
                                    <button type="button" class="btn btn-primary" id="addAttr" onclick="addProperty()">添加属性</button>
                                </div>
                            </fieldset>
                        </form>

                    </div>
                </div><!--/span-->

            </div><!--/row-->
        </div>
    </div>
</div>

<div class="modal hide fade" id="myModal">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h3>Settings</h3>
    </div>
    <div class="modal-body">
        <p>Here settings can be configured...</p>
    </div>
    <div class="modal-footer">
        <a href="#" class="btn" data-dismiss="modal">Close</a>
        <a href="#" class="btn btn-primary">Save changes</a>
    </div>
</div>
<div class="common-modal modal fade" id="common-Modal1" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-content">
        <ul class="list-inline item-details">
            <li><a href="http://sc.chinaz.com">Admin templates</a></li>
            <li><a href="http://sc.chinaz.com">Bootstrap themes</a></li>
        </ul>
    </div>
</div>
<div class="clearfix"></div>


<div th:replace="new::common_js"></div>
<script>
    var isCheckName=true;
    //返回上一页
    function toDevice(){
        window.history.back(-1);
    }

    //设备图片预览
    function previewPic(){
        //获取显示图片对象
        var preview = document.getElementById("showImg");   // 通过元素节点查找： document.querySelector('img');
        //获取选中图片对象（包含文件的名称、大小、类型等，如file.size）
        var file = document.getElementById("pic").files[0];
        //声明js的文件流
        var reader = new FileReader();
        if(file){
            //通过文件流将文件转换成Base64字符串
            reader.readAsDataURL(file);
            //转换成功后
            reader.onloadend = function ()
            {
                //将转换结果赋值给img标签
                preview.src = reader.result;
                //输出结果
                // document.getElementById("showText").value = reader.result;
            }
        }
        else{
            preview.src = "";
        }
    }

    //设备高亮图片预览
    function previewPic1(){
        //获取显示图片对象
        var preview = document.getElementById("showImg1");   // 通过元素节点查找： document.querySelector('img');
        //获取选中图片对象（包含文件的名称、大小、类型等，如file.size）
        var file = document.getElementById("highlightPic").files[0];
        console.log(file);
        //document.querySelector('input[type=file]').files[0];
        //声明js的文件流
        var reader = new FileReader();
        if(file){
            //通过文件流将文件转换成Base64字符串
            reader.readAsDataURL(file);
            //转换成功后
            reader.onloadend = function ()
            {
                //将转换结果赋值给img标签
                preview.src = reader.result;
                //输出结果
                // console.log(reader.result);
                // console.log(typeof reader.result);
                // document.getElementById("showText").value = reader.result;
            }
        }
        else{
            preview.src = "";
        }
    }

    //提交修改表单
    function editDevice(){
        var formData=new FormData($("#form2")[0]); //表单的formData数据
        var deviceId=document.getElementById("deviceId");//设备id
        var deviceIdValue=deviceId.innerHTML;
        var typeId=document.getElementById("typeId");//设备类型
        var typeIdValue=typeId.value;
        var start=document.getElementById("timeStart");//设备开启的起始时间
        var end=document.getElementById("timeEnd");//结束时间
        var startTime=Number(start.value);
        var endTime=Number(end.value);
        var deviceName=document.getElementById("deviceName");//设备名称
        var conversionRate=document.getElementById("conversionRate");//能源比
        var devCode=document.getElementById("devCode");//设备编号
        var power=document.getElementById("power");//平均每小时产能
        var cap=document.getElementById("cap");//上限
        var x=document.getElementById("x"); //x坐标
        var y=document.getElementById("y");//y坐标
        if(deviceName.value==""){
            layer.alert('设备名不能为空', {

                icon: 5,

                title: "提示"

            });return false;
        }
        if(devCode.value==""){
            layer.alert('设备名不能为空', {

                icon: 5,

                title: "提示"

            });return false;
        }
        if(power.value==""){
            layer.alert('功率不能为空', {

                icon: 5,

                title: "提示"

            });return false;
        }
        if(conversionRate.value==""){
            layer.alert('能效比不能为空', {

                icon: 5,

                title: "提示"

            });return false;
        }
        if(cap.value==""){
            layer.alert('上限不能为空', {

                icon: 5,

                title: "提示"

            });return false;
        }
        if(x.value==""){
            layer.alert('X坐标不能为空', {

                icon: 5,

                title: "提示"

            });return false;
        }
        if(y.value==""){
            layer.alert('Y坐标不能为空', {

                icon: 5,

                title: "提示"

            });return false;
        }
        console.log(typeIdValue);
        formData.append("deviceId",deviceIdValue);
        //  var  mydata = document.getElementById("pic").files[0];
        //  var mydata1=document.getElementById("highlightPic").files[0];
        // var  formData = new FormData();
        // formData.append("pic", mydata);
        // formData.append("highlightPic",mydata1);
        //判断设备名是否可以使用
        if(isCheckName==false){
            layer.alert('请输入未被使用的设备名', {

                icon: 5,

                title: "提示"

            });return false;
        }
        if((startTime-endTime)>=0){
            layer.alert('请输入合理的时间段', {

                icon: 5,

                title: "提示"

            });return false;
        }
        $.ajax({
            type: "POST",
            data:formData,
            url: "/power/device/update",
            processData:false,
            contentType:false,
            success: function(data) {
                console.log("成功");
                if(isCheckName==true) {
                    window.location.href = "/power/device/" + typeIdValue;
                }
            },
        })
    }
    //设备名是否重复
    function checkName(){
        var deviceName=$("#deviceName").val();
        deviceName=$.trim(deviceName);
        console.log(deviceName);
        $.ajax({
            type: "GET",
            data:{deviceName:deviceName},
            url: "/power/device/check",
            success: function(data) {
                console.log(data.check);
                if(data.check=="yes"){
                    var span=document.createElement("span");
                    span.setAttribute("class","greenColor");
                    span.innerHTML="该设备名可以使用";
                    $("#checkName").html(span);
                    isCheckName=true;
                }
                if(data.check=="no"){
                    var span=document.createElement("span");
                    span.setAttribute("class","redColor");
                    span.innerHTML="该设备名已存在，请使用其他设备名";
                    $("#checkName").html(span);
                    isCheckName=false;
                }
            },
        })
    }
</script>

</body>
</html>
